<template>
	<view class="contianer" :class="'wp-' + platform">
		<view class="mainpageitem">
			<view class="margin-top padding"></view>
			<view class="margin-top padding"></view>
			<view class="metting-box">
				<view class="user-box" >
					<!--  shape="square" -->
					<u-avatar :size="60" :src="configs.avatarUrl+'/' + callInfo.uid+'.jpg'">
					</u-avatar>
					<text class="user-name">{{callInfo.name}}</text>
				</view>
				
				<view class="cu-list menu">
					<view class="cu-item" style="padding: 20upx 30upx;">
						<view class="content">
							<text>会议号</text>
						</view>
						<view class="action" style="max-width: 70%;">
							{{callInfo.tag}}
						</view>
					</view>
					
					
					
				</view>
				
			</view>
			<view class="flex flex-direction margin-top padding">
				<button class="cu-btn lg bg-limegreen" @tap="handleAddMetting">立即加入</button>
				<button class="cu-btn lg bg-red margin-top" @tap="handleCancle">稍后加入</button>
			</view>
		</view>
	</view>
</template>

<script>
import * as API_liveKit from '@/api/livekit';
import core from '@/core';
import store from '@/store'
import configs from '@/config/config'
export default {
	data() {
		return{
			configs:configs,
			theme: core.style,
			text: core.langs,
			platform: core.platform,
			
			roomTag:'',
			callInfo:{},
		}
	},
	onLoad(op){
		this.roomTag=op.tag;
		this.handleShowAcceptLayer(this.roomTag)
	},
	methods:{
		// 来电会议弹窗
		async handleShowAcceptLayer(roomTag){
			const resp = await this.handleGetRoomInfo(roomTag)
			if (resp && resp.code == 200) {
				this.callInfo = resp.data
				// data.isShowAcceptLayer = true;
				try {
					// playAudio(1);
				} catch (error) { }
			}
		},
		// 获取房间详情
		async handleGetRoomInfo(roomTag){
			let params = {
				roomTag: roomTag
			}
			const resp = await API_liveKit.getRoomInfo(params)
			if (resp.code == 200) {
				return resp
			} else {
				this.toast('房间不存在')
				return false
			}
		},
		handleAddMetting(){
			uni.navigateTo({
			  url: '/pages/livekit/metting?type=metting&tag='+this.roomTag
			})
		},
		async handleCancle(){
			store.commit('user/SET_ONLINE', false)
			// let roomList = []
			// let member = this.callInfo.member
			// if (member) {
			// 	Object.keys(member).map(item => {
			// 		roomList.push(
			// 			{
			// 				id: item,
			// 				name: member[item]
			// 			}
			// 		)
			// 	})
			// }
			// const messageData = {
			// 	meetType: this.callInfo.dueTime ? 'order' : 'quick',
			// 	roomList: [{ id: this.user.id, name: this.user.name }, {id:this.callInfo.uid, name: this.callInfo.name}, ...roomList],
			// 	time: '00:00:00',
			// 	roomTag: this.roomTag,
			// 	roomInfo: { ...this.callInfo }
			// }
			// pauseAudio();
			let params = {
				roomTag: this.roomTag,
			}
			await API_liveKit.rejectMeet(params) // 拒绝会议
			uni.reLaunch({
			  url: '/pages/index/index'
			})
		},
	}
}
</script>
<style lang="scss" scoped>
.metting-box{
	width: 90%;
	margin: 40rpx auto;
	border-radius: 20rpx;
	background-color: #fff;
	padding: 20rpx;
	padding-top: 60rpx;
	.user-box{
		display: flex;
		flex-direction: column;
		align-items: center;
		.user-name{
			margin-top: 20rpx;
		}
	}
	.user-box-list{
		display:flex;
		flex-wrap: wrap;
		.user-item{
			margin-left:20rpx;
			display:flex;
			flex-direction: column;
			align-items: center;
			.user-name{
				margin-top: 20rpx;
				font-size:24rpx;
			}
		}
	}
}
</style>